# Function to configure IDL compilation
function(configure_corba_idl IDL_NAME GENERATED_DIR)
    # Set IDL file path
    set(IDL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${IDL_NAME}.idl)

    # Create directory for generated files
    file(MAKE_DIRECTORY ${GENERATED_DIR})

    # Set generated file paths
    set(IDL_CPP ${GENERATED_DIR}/${IDL_NAME}C.cpp)
    set(IDL_CH ${GENERATED_DIR}/${IDL_NAME}C.h)
    set(IDL_CINL ${GENERATED_DIR}/${IDL_NAME}C.inl)
    set(IDL_SCPP ${GENERATED_DIR}/${IDL_NAME}S.cpp)
    set(IDL_SH ${GENERATED_DIR}/${IDL_NAME}S.h)
    set(IDL_SICPP ${GENERATED_DIR}/${IDL_NAME}I.cpp)
    set(IDL_SIH ${GENERATED_DIR}/${IDL_NAME}I.h)

    # Define custom command for IDL compilation
    add_custom_command(
        OUTPUT ${IDL_CPP} ${IDL_CH} ${IDL_CINL} ${IDL_SCPP} ${IDL_SH} ${IDL_SICPP} ${IDL_SIH}
        COMMAND $ENV{ACE_ROOT}/bin/tao_idl -Sa -St -GI ${IDL_FILE} -o ${GENERATED_DIR}
        DEPENDS ${IDL_FILE}
        COMMENT "Compiling IDL file ${IDL_FILE}"
    )

    message("==>用户需要将生成的服务文件 拷贝到 源码目录下 ${IDL_SICPP} ${IDL_SIH}!")
    # Return the generated file paths
    set(IDL_GENERATED_FILES_S
        ${IDL_CPP} ${IDL_SCPP}  ${IDL_CH} ${IDL_SH} ${IDL_CINL}
        PARENT_SCOPE
    )
    set(IDL_GENERATED_FILES_C
        ${IDL_CPP} ${IDL_CH}  ${IDL_SH} ${IDL_CINL}
        PARENT_SCOPE
    )
endfunction()